package com.fesine.netapply.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public DateUtil() {
    }

    public static String formatDate(Date date, String format) {
        String result = "";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        if(date != null) {
            result = sdf.format(date);
        }

        return result;
    }

    public static Date formatString(String str, String format) {
        if(StringUtil.isEmpty(str)) {
            return null;
        } else {
            SimpleDateFormat sdf = new SimpleDateFormat(format);

            try {
                return sdf.parse(str);
            } catch (ParseException var4) {
                var4.printStackTrace();
                return null;
            }
        }
    }

    public static String getCurrentDateStr() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        return sdf.format(date);
    }
}
